﻿#pragma once
#include <fstream>
#include "entities.h"

class JsonSaver {

private:
	std::ofstream fout;
	
public:
	JsonSaver() = delete;
	JsonSaver(std::string filename);
	/// <summary>
	/// 析构函数
	/// 关闭文件输出流
	/// 关闭单例访问的文件
	/// </summary>
	virtual ~JsonSaver();

private:
	/// <summary>
	/// 写入一条识别结果
	/// </summary>
	/// <param name="r"></param>
	void write(Record &r);

private:
	static JsonSaver* s;
public:
	/// <summary>
	/// 静态方法，写入一条识别结果记录
	/// </summary>
	/// <param name="r">识别结果记录</param>
	static void Write(Record& r);
};